package test;

import java.awt.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.lang.Object;

public class test{
	public static void main(String[] args) throws IOException{


		ArrayList<Integer> numbers = new ArrayList<Integer>(); 
		for (int i = 51;i<59;i++){ //31-80
			if (!(i==55)){
				numbers.add(i);
			}
		}

		// concatenate numbers list
		int n_rep = 5;
		ArrayList<Integer> n_r = new ArrayList<Integer>(); 
		for (int i = 0;i<n_rep;i++){
			n_r.addAll(numbers);
		}

		System.out.println("initial list :"+ n_r);

		Collections.shuffle(n_r);
		System.out.println("after first shuffle :"+ n_r);

		ArrayList<Integer> n_r_prand = new ArrayList<Integer>(); 


		boolean cond1 = true;
		boolean cond2 = false;
		int N =n_r.size();

		n_r_prand.add(n_r.get(0));
		n_r.remove(0);
		for (int i = 1;i<N;i++){

			n_r_prand.add(n_r.get(0));
			cond1 =  (n_r_prand.get(i)==n_r_prand.get(i-1));
			if (i>1){
				cond2 = ((n_r_prand.get(i)<55)&&(n_r_prand.get(i-1)<55)&&(n_r_prand.get(i-2)<55))||((n_r_prand.get(i)>55)&&(n_r_prand.get(i-1)>55)&&(n_r_prand.get(i-2)>55));
				System.out.println("i-2 :"+ n_r_prand.get(i-2));

			}			
			System.out.println("i-1 :"+ n_r_prand.get(i-1));
			System.out.println("i :"+ n_r_prand.get(i));

			while (cond1||cond2){
				Collections.shuffle(n_r);
				n_r_prand.set(i, n_r.get(0));
				cond1 = (n_r_prand.get(i)==n_r_prand.get(i-1));					
				if (i>1){
					cond2 = ((n_r_prand.get(i)<55)&&(n_r_prand.get(i-1)<55)&&(n_r_prand.get(i-2)<55))||((n_r_prand.get(i)>55)&&(n_r_prand.get(i-1)>55)&&(n_r_prand.get(i-2)>55));
					System.out.println("i-2 :"+ n_r_prand.get(i-2));

				}	
				System.out.println("i-1 :"+ n_r_prand.get(i-1));
				System.out.println("i :"+ n_r_prand.get(i));
				if (cond2){System.out.println("bad2");}
				if (cond1){System.out.println("bad1");}


			}

			n_r.remove(0);

		}

		System.out.println("pseudo randomization :"+ n_r_prand);

	}
}
